package com.lzq.chatroom_project.service.impl;

import com.lzq.chatroom_project.dao.FriendMapper;
import com.lzq.chatroom_project.model.AddFriendRequest;
import com.lzq.chatroom_project.model.Friend;
import com.lzq.chatroom_project.service.IFriendService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class FriendServiceImpl implements IFriendService {

    @Autowired
    private FriendMapper friendMapper;

    @Override
    public List<Friend> getFriendListById(Integer userId) {
        log.info("开始执行getFriendListById方法,接收参数:userId:{}",userId);
        return friendMapper.selectFriendList(userId);
    }

    @Override
    public List<Friend> findFriend(Integer selfId, String friendName) {
        log.info("开始执行findFriend方法,接收参数:selfId:{},friendName:{}",selfId,friendName);
        return friendMapper.findFriend(selfId,friendName);
    }

    @Override
    public void addFriendRequest(int userId, int friendId, String reason) {
        log.info("开始执行addFriendRequest方法,接收参数:userId:{},friendId:{},reason:{}",userId,friendId,reason);
        friendMapper.addFriendRequest(userId,friendId,reason);
    }

    @Override
    public List<AddFriendRequest> getFriendRequest(int toUserId) {
        log.info("开始执行getFriendRequest方法,接收参数:userId:{}",toUserId);
        return friendMapper.getFriendRequest(toUserId);
    }

    @Override
    public void deleteFriendRequest(int friendId, int userId) {
        log.info("开始执行deleteFriendRequest方法,接收参数:friendId:{},userId:{}",friendId,userId);
        friendMapper.deleteFriendRequest(friendId,userId);
    }

    @Override
    public void addFriend(int friendId, int userId,String friendName,String userName) {
        log.info("开始执行addFriend方法,接收参数:friendId:{},userId:{},friendName:{},userName:{}",friendId,userId,friendName,userName);
        friendMapper.addFriend(friendId,userId,friendName,userName);
    }

    @Override
    public void updateFriendNickname(int friendId, int userId, String friendNickname) {
        log.info("开始执行updateFriendNickname方法,接收参数:friendId:{},userId:{},friendNickname:{}",friendId,userId,friendNickname);
        friendMapper.updateFriendNickname(friendId,userId,friendNickname);
    }

}
